package com.flexcloudsdk.environment;
import java.util.logging.Logger;

import com.flexcloudsdk.channel.CloudChannelMessage;
import com.flexcloudsdk.fetch.CloudURLFetchService;
import com.google.appengine.api.utils.SystemProperty;

@SuppressWarnings("unused")
public class CloudEnvironment {
	private static final Logger log = Logger.getLogger(CloudEnvironment.class.getName());
	private String sourceClass;
	private String sourceMethod;

	public CloudEnvironment() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		sourceClass = CloudChannelMessage.class.getName();
		log.info("CloudEnvironment has been created by BlazeDS");
	}
	
	public Boolean isProduction() {
		Boolean onProd = false;
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		if (SystemProperty.environment.value() ==	SystemProperty.Environment.Value.Production)
		{
			onProd = true;
		}
		return onProd;
	}
	public Boolean isDevelopment() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		Boolean onDev = false;
		if (SystemProperty.environment.value() ==	SystemProperty.Environment.Value.Development)
		{
			onDev = true;
		}
		return onDev;
	}
	
	public String version() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return SystemProperty.version.get();
	}
	
	public String appVerion() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return SystemProperty.applicationVersion.get();
	
	}
	public String appId() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return SystemProperty.applicationId.get();	
	}
	
	public String fileSeparator() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return System.getProperty("file.separator");
	}
	
	public String pathSeparator() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("path.separator");
	}
	
	public String lineSeparator() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("line.separator");
	}
	
	public String javaVersion() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.version");
	}
	
	public String javaVendor() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.vendor");	
	}
	
	public String javaVendorUrl() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.vendor.url");
	}
	
	public String javaClassVersion() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.class.version");
	}
	
	public String javaSpecVersion() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.specification.version");	
	}
	
	public String javaSpecVendor() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.specification.vendor");
	}
	
	public String javaSpecName() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.specification.name");
	}
	
	public String javaVMVendor() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.vm.vendor");	
	}
	
	public String javaVMName() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.vm.name");	
	}
	
	public String javaVMSpecVersion() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.vm.specification.version");
	}
	
	public String javaVMSpecVendor() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.vm.specification.vendor");
	}
	
	public String javaVMSpecName() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("java.vm.specification.name");
	}
	
	public String userDir() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return System.getProperty("user.dir");
	}
}
